package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.QImMydtj;
import com.ruoyi.system.service.IQImMydtjService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * IM满意度Controller
 * 
 * @author ruoyi
 * @date 2024-06-25
 */
@Controller
@RequestMapping("/system/mydtj")
public class QImMydtjController extends BaseController
{
    private String prefix = "system/mydtj";

    @Autowired
    private IQImMydtjService qImMydtjService;

    @RequiresPermissions("system:mydtj:view")
    @GetMapping()
    public String mydtj()
    {
        return prefix + "/mydtj";
    }

    /**
     * 查询IM满意度列表
     */
    @RequiresPermissions("system:mydtj:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(QImMydtj qImMydtj)
    {
        startPage();
        List<QImMydtj> list = qImMydtjService.selectQImMydtjList(qImMydtj);
        return getDataTable(list);
    }

    /**
     * 导出IM满意度列表
     */
    @RequiresPermissions("system:mydtj:export")
    @Log(title = "IM满意度", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(QImMydtj qImMydtj)
    {
        List<QImMydtj> list = qImMydtjService.selectQImMydtjList(qImMydtj);
        ExcelUtil<QImMydtj> util = new ExcelUtil<QImMydtj>(QImMydtj.class);
        return util.exportExcel(list, "IM满意度数据");
    }

    /**
     * 新增IM满意度
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存IM满意度
     */
    @RequiresPermissions("system:mydtj:add")
    @Log(title = "IM满意度", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(QImMydtj qImMydtj)
    {
        return toAjax(qImMydtjService.insertQImMydtj(qImMydtj));
    }

    /**
     * 修改IM满意度
     */
    @RequiresPermissions("system:mydtj:edit")
    @GetMapping("/edit/{kfName}")
    public String edit(@PathVariable("kfName") String kfName, ModelMap mmap)
    {
        QImMydtj qImMydtj = qImMydtjService.selectQImMydtjByKfName(kfName);
        mmap.put("qImMydtj", qImMydtj);
        return prefix + "/edit";
    }

    /**
     * 修改保存IM满意度
     */
    @RequiresPermissions("system:mydtj:edit")
    @Log(title = "IM满意度", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(QImMydtj qImMydtj)
    {
        return toAjax(qImMydtjService.updateQImMydtj(qImMydtj));
    }

    /**
     * 删除IM满意度
     */
    @RequiresPermissions("system:mydtj:remove")
    @Log(title = "IM满意度", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(qImMydtjService.deleteQImMydtjByKfNames(ids));
    }
}
